package megamu.mesh;

import com.jellyfishumbrella.GL.Vector3d;
import com.jellyfishumbrella.GL.Vertex;
import com.jellyfishumbrella.util.EqualsUtil;
import com.jellyfishumbrella.util.HashCodeUtil;

public class Edge {
	protected int	fHashCode	= 0;
	public Corner	corner1;
	public Corner	corner2;
	public Site		site1;
	public Site		site2;

	public Edge() {

	}

	public Edge(Corner A, Corner B) {
		corner1 = A;
		corner2 = B;
	}

	public String toString() {
		if (corner1.vert.x() < corner2.vert.x()) {
			return corner1.toString() + "," + corner2.toString();
		} else {
			return corner2.toString() + "," + corner1.toString();
		}
	}

	public boolean equals(Object aThat) {
		if (this == aThat) {
			return true;
		} else if (!(aThat instanceof Edge)) {
			return false;
		} else {
			Edge that = (Edge) aThat;
			return this.corner1.equals(that.corner1) && this.corner2.equals(that.corner2);

		}
	}

	public int hashCode() {
		if (fHashCode == 0) {
			int result = HashCodeUtil.SEED;
			result = HashCodeUtil.hash(result, this.corner1);
			result = HashCodeUtil.hash(result, this.corner2);
			fHashCode = result;
		}
		return fHashCode;
	}
}
